# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName : zsj.py
# @Time     : 2024/4/13 19:09
# @Author   : Robot-Zsj
"""
description:

i:
7
1 2 2 7 3 6 1
3

o:
10
"""
length = int(input())
nums = list(map(int, input().split()))
n = int(input())


def getResult():
    leftSum = 0
    rightSum = sum(nums[length - n:])

    if length == n:
        return rightSum

    sumV = leftSum + rightSum

    ans = sumV

    l = 0

    r = length - n
    while l < n:
        sumV += nums[l] - nums[r]
        ans = max(ans, sumV)
        l += 1
        r += 1

    return ans


print(getResult())
